#! /bin/sh /usr/share/dpatch/dpatch-run
## 01_debian-patch.dpatch by LI Daobing <lidaobing@gmail.com>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: New patch generated from cdict 0.1-5 diff.gz

@DPATCH@
diff -urNad cdict~/Makefile cdict/Makefile
--- cdict~/Makefile	1997-08-24 10:46:25.000000000 +0800
+++ cdict/Makefile	2007-05-22 20:45:37.000000000 +0800
@@ -2,9 +2,10 @@
 CFLAGS=-O2
 LIBS=-lgdbm
 
-cdict: cdict5.o CE.o b2g_tables.o
-	$(CC) cdict5.o CE.o b2g_tables.o -o cdict $(LIBS)
-	strip cdict
+all: cdict.bin Index.gdbm
+
+cdict.bin: cdict5.o CE.o b2g_tables.o
+	$(CC) cdict5.o CE.o b2g_tables.o -o $@ $(LIBS)
 
 cdict5.o: cdict5.c cdict5.h cdict5.conf
 	$(CC) $(CFLAGS) -c cdict5.c
@@ -19,12 +20,21 @@
 	$(CC) $(CFLAGS) endian.c -o endian
 	./endian
 
-index:  
+Index.gdbm: etdic/a.i50
 	$(CC) $(CFLAGS) index.c -o indexer $(LIBS)
 	$(CC) $(CFLAGS) index2.c -o indexer2 $(LIBS)
 	./indexer
 	./indexer2
 	rm -f *.idx
 
+install: all
+	install -d $(DESTDIR)/usr/bin $(DESTDIR)/usr/lib/cdict
+	install -m755 debian/cdict.wrapper $(DESTDIR)/usr/bin/cdict
+	install -m755 cdict.bin $(DESTDIR)/usr/bin
+	install -m644 Index.gdbm $(DESTDIR)/usr/lib/cdict
+	install -m644 etdic/* $(DESTDIR)/usr/lib/cdict
+
 clean:
-	rm -f *.o cdict endian indexer indexer2 cdict5.conf Index.gdbm *.idx
+	rm -f *.o cdict.bin endian indexer indexer2 cdict5.conf Index.gdbm *.idx
+
+
diff -urNad cdict~/cdict5.c cdict/cdict5.c
--- cdict~/cdict5.c	1997-12-15 22:12:09.000000000 +0800
+++ cdict/cdict5.c	2007-05-22 20:45:03.000000000 +0800
@@ -494,7 +494,7 @@
   close(L2indexFD);
 }
   
-void main(int argc, char **argv) {
+int main(int argc, char **argv) {
   int i;
   unsigned char buf[4096], word[4096];
 
diff -urNad cdict~/cdict5.h cdict/cdict5.h
--- cdict~/cdict5.h	1997-06-03 09:46:30.000000000 +0800
+++ cdict/cdict5.h	2007-05-22 20:45:03.000000000 +0800
@@ -1,27 +1,28 @@
-#define INDEX_PATH	"/usr/local/lib/etdic"
-#define DICT_PATH	"/usr/local/lib/etdic"
+#define INDEX_PATH	"/usr/lib/cdict"
+#define COMPILE_DICT_PATH	"etdic"
+#define DICT_PATH	"/usr/lib/cdict"
 #define MAX_MATCHES	50
 #define COLUMN		75 
-#define PAGER		"/usr/bin/more"
+/* #define PAGER		"/usr/bin/less -r" */
 
 #define NO_ANSI			""
-#define ANSI_RED		"\033[31;40m"
-#define ANSI_RED_BOLD		"\033[31;40;1m"
-#define ANSI_GREEN		"\033[32;40m"
-#define ANSI_GREEN_BOLD		"\033[32;40;1m"
-#define ANSI_YELLOW		"\033[33;40m"
-#define ANSI_YELLOW_BOLD	"\033[33;40;1m"
-#define ANSI_BLUE		"\033[34;40m"
-#define ANSI_BLUE_BOLD		"\033[34;40;1m"
-#define ANSI_MAGENTA		"\033[35;40m"
-#define ANSI_MAGENTA_BOLD	"\033[35;40;1m"
-#define ANSI_CYAN		"\033[36;40m"
-#define ANSI_CYAN_BOLD		"\033[36;40;1m"
-#define ANSI_WHITE		"\033[37;40m"
-#define ANSI_WHITE_BOLD		"\033[37;40;1m"
+#define ANSI_RED		"\033[31m"
+#define ANSI_RED_BOLD		"\033[31;1m"
+#define ANSI_GREEN		"\033[32m"
+#define ANSI_GREEN_BOLD		"\033[32;1m"
+#define ANSI_YELLOW		"\033[33m"
+#define ANSI_YELLOW_BOLD	"\033[33;1m"
+#define ANSI_BLUE		"\033[34m"
+#define ANSI_BLUE_BOLD		"\033[34;1m"
+#define ANSI_MAGENTA		"\033[35m"
+#define ANSI_MAGENTA_BOLD	"\033[35;1m"
+#define ANSI_CYAN		"\033[36m"
+#define ANSI_CYAN_BOLD		"\033[36;1m"
+#define ANSI_WHITE		"\033[37m"
+#define ANSI_WHITE_BOLD		"\033[37;1m"
 #define ANSI_RESET		"\033[0m"
 
-#define KEYWORD_COLOR		ANSI_YELLOW_BOLD
+#define KEYWORD_COLOR		ANSI_BLUE_BOLD
 #define WORD_CLASS_COLOR	ANSI_RED_BOLD
 #define IDIOM_COLOR		ANSI_YELLOW
 #define EXAMPLE_COLOR		ANSI_MAGENTA
diff -urNad cdict~/endian.c cdict/endian.c
--- cdict~/endian.c	1997-05-15 15:11:51.000000000 +0800
+++ cdict/endian.c	2007-05-22 20:45:03.000000000 +0800
@@ -4,7 +4,7 @@
   char c[4];
 } u;
 
-void main() {
+int main() {
 
   FILE *FD;
 
diff -urNad cdict~/index.c cdict/index.c
--- cdict~/index.c	1997-05-15 15:11:51.000000000 +0800
+++ cdict/index.c	2007-05-22 20:45:03.000000000 +0800
@@ -7,6 +7,7 @@
 #include <ctype.h>
 #include <gdbm.h>
 #include <time.h>
+#include <stdint.h>
 #include "cdict5.h"
 
 GDBM_FILE f;
@@ -143,12 +144,12 @@
 
 }
 
-void main() {
+int main() {
   int i, index_len, startTime, word_count;
   int indexFD, dictFD;
   unsigned char o;
   unsigned char buf[128], index_path[128], dict_path[128];
-  long *indice;
+  int32_t *indice;
 
   unlink("Index.gdbm");
   f=gdbm_open("Index.gdbm", 0, GDBM_WRCREAT|GDBM_FAST, 0600, NULL);
@@ -159,8 +160,8 @@
   }
   
   for (o='a'; o<='z'; o++) {
-    sprintf(index_path, DICT_PATH "/%c.i50", o);
-    sprintf(dict_path, DICT_PATH "/%c.d50", o);
+    sprintf(index_path, COMPILE_DICT_PATH "/%c.i50", o);
+    sprintf(dict_path, COMPILE_DICT_PATH "/%c.d50", o);
     indexfile[0]=o;
     word_count = 0;
 
@@ -184,7 +185,7 @@
     index_len = lseek(indexFD, 0, SEEK_END);
     lseek(indexFD, 0, 0);
   
-    indice = (long*)malloc(index_len);
+    indice = (int32_t*)malloc(index_len);
     index_len = read(indexFD, (unsigned char*)indice, index_len);
     if (index_len <= 0) {
       fprintf(stderr, "%s corrupted\n", index_path);
diff -urNad cdict~/index2.c cdict/index2.c
--- cdict~/index2.c	1997-05-15 15:11:51.000000000 +0800
+++ cdict/index2.c	2007-05-22 20:45:03.000000000 +0800
@@ -11,7 +11,7 @@
 FILE      *FD;
 char indexfile[]="?.idx";
 
-void main() {
+int main() {
   int fd, fd2, i, flen;
   unsigned char *buf, o;
   datum key, data;
